﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace DungeonCraft.Engine
{
    public class SpriteManager
    {
        Dictionary<string, Texture2D> sprites = new Dictionary<string, Texture2D>();
        Dictionary<string, SpriteFont> fonts = new Dictionary<string, SpriteFont>();
        private ContentManager content;

        public SpriteManager(ContentManager content)
        {
            this.content = content;
        }

        public Texture2D getSprite(string spriteName)
        {
            Texture2D sprite;
            if (!sprites.TryGetValue(spriteName, out sprite))
            {
                sprite = content.Load<Texture2D>(spriteName);
                sprites.Add(spriteName, sprite);
                return sprite;
            }

            return sprite;
            
        }

        public SpriteFont getFont(string fontName)
        {
            SpriteFont sprite;
            if (!fonts.TryGetValue(fontName, out sprite))
            {
                sprite = content.Load<SpriteFont>(fontName);
                fonts.Add(fontName, sprite);
                return sprite;
            }

            return sprite;
        }
    }
}
